﻿using HDS.Data;
using HDS.IService.Master;
using HDS.Model.Entity.Master;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace HDS.Service.Master
{
    public class SupplierApiConfigService : ISupplierApiConfigService
    {
        private MasterDbContext db = new MasterDbContext();

        public async Task<SupplierApiConfig> Get(string supplier)
        {
            return await db.SupplierApiConfig.GetSingleAsync(e => e.Supplier.Equals(supplier));
        }

        public async Task<SupplierApiConfig> GetByAbbr(string supplierAbbr)
        {
            return await db.SupplierApiConfig.GetSingleAsync(e => e.SupplierAbbr.Equals(supplierAbbr));
        }

        public async Task<List<SupplierApiConfig>> GetList(Expression<Func<SupplierApiConfig, bool>> whereExpression)
        {
            return await db.Db.Queryable<SupplierApiConfig>().WhereIF(whereExpression != null, whereExpression).ToListAsync();
        }
    }
}
